package com.example.accessibilityhelper.addfriend

import android.accessibilityservice.AccessibilityService
import android.view.accessibility.AccessibilityEvent
import com.example.accessibilityhelper.Step
import com.example.accessibilityhelper.WeChatHelperService
import com.example.accessibilityhelper.config.Id
import com.example.accessibilityhelper.util.click

/**
 * 第一步，回到消息列表主页,点击其他企业
 */
class AddFriendFromMainPageStep1: Step() {

    override fun match(service: AccessibilityService, event: AccessibilityEvent): Boolean {
        return event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
                && event.className == WeChatHelperService.PAGE.MAIN_PAGE
    }

    override fun execute(service: AccessibilityService, event: AccessibilityEvent) {
        service.rootInActiveWindow.findAccessibilityNodeInfosByViewId(Id.main_corporation_button)
            .firstOrNull()
            ?.click()
    }


}